import type { CSSProperties } from "vue"
import type { UploadFile, UploadFiles } from 'element-plus'
import type { RuleItem } from "./rule"

// export interface FormOptions {
//   type: 'date-picker' | 'input' | 'select' | 'option' | 'upload' | 'checkbox-group' | 'checkbox' | 'upload';
//   value?: any;
//   label?: string;
//   prop?: string;
//   rules?: RuleItem[];
//   placeholder?: string;
//   attrs?: {
//     clearable?: boolean;
//     showPassword?: boolean;
//     disabled?: boolean;
//     style?: CSSProperties;
//     filterable?: boolean;
//     remote?: boolean;
//   };
//   children?: FormOptions[];
//   uploadAttrs?: {
//     action: string;
//     headers?: object;
//     method?: 'post' | 'put' | 'patch';
//     multiple?: boolean;
//     data?: any;
//     name?: string;
//   }
// }

export type componentType = 
  | 'date-picker' 
  | 'input' 
  | 'select' 
  | 'option' 
  | 'upload' 
  | 'checkbox-group' 
  | 'checkbox' 
  | 'upload';

export interface FormOptionItem {
  type: componentType;
  prop: string;
  label?: string;
  value?: any;
  placeholder?: string;
  rules?: RuleItem[];
  attrs?: Record<string, any>;
  uploadAttrs?: Record<string, any>;
  children?: FormOptionChild[];
}

export interface FormOptionChild {
  type: componentType;
  label?: string;
  value?: any;
}

export type FormOptions = FormOptionItem[];

export interface FormEmits {
  (e: 'on-preview', file: UploadFile): void
  (e: 'on-remove', file: UploadFile, fileList: UploadFiles): void
  (e: 'on-success', params: { response: any; file: UploadFile; fileList: UploadFiles }): void
  (e: 'on-error', error: Error, file: UploadFile, fileList: UploadFiles): void
  (e: 'on-progress', event: ProgressEvent, file: UploadFile, fileList: UploadFiles): void
  (e: 'on-change', file: UploadFile, fileList: UploadFiles): void
  (e: 'on-exceed', files: File[], fileList: UploadFiles): void
  (e: 'before-upload', file: UploadFile): void
  (e: 'before-remove', file: UploadFile, fileList: UploadFiles): void
}